/**
 * Created by Administrator on 2015/10/23 0023.
 */
//地图初始化
var map = new AMap.Map("mapContainer", {
    resizeEnable: true,
    //二维地图显示视口
    //地图中心点
    center: [116.397428, 39.90923],
    //地图显示的缩放级别
    zoom: 13
});
//获取用户所在城市信息
function showCityInfo() {
    //加载城市查询插件
    AMap.service(["AMap.CitySearch"], function() {
        //实例化城市查询类
        var citysearch = new AMap.CitySearch();
        //自动获取用户IP，返回当前城市
        citysearch.getLocalCity(function(status, result) {
            if (status === 'complete' && result.info === 'OK') {
                if (result && result.city && result.bounds) {
                    var cityinfo = result.city;
                    var citybounds = result.bounds;
                    document.getElementById('info').innerHTML = "您当前所在城市：" + cityinfo + "";
                    //地图显示当前城市
                    map.setBounds(citybounds);
                }
            } else {
                document.getElementById('info').innerHTML = "您当前所在城市：" + result.info + "";
            }
        });
    });
}